;:sys36864
	;.opt oo
	*= $cedf
; -------------------------
; pokefinder 1.0  (c) 6.92
; nikolaus heusler
; XXXXXXXXXXXX  XX
; XXXX XXXXXXXX XX
; -------------------------
; **** benutzerschnittstelle
	lda #<fra
	ldy #>fra	;frage
	jsr $ab1e	;ausgeben
	ldx #0
getk	jsr $ffcf	;eingabe holen
	cmp #13
	beq cr	;ende mit return
	sta 820,x	;eingabe speichern
	inx	;und weiter
	bne getk
cr	lda #0
	sta 820,x
	tax
	stx 2	;eingabe numerisch wandeln
calc	lda 820,x
	beq fertig	;schon alle stellen
	lda 2	;alter wert
	asl
	asl	;mal 10
	adc 2
	asl
	sta 2
	lda 820,x
	and #15
	clc
	adc 2	;plus neuer wert
	sta 2
	inx
	bne calc
fertig	jsr $aad7	;return
	ldy #$c
	jsr $f12f	;'searching'
	jsr $aad7
	jsr $aad7
	ldy #0
	sty 3
	lda #4
	sta 4	;suche ab $400
	lda #48
	sei
	sta 1	;rom ausblenden
; **** haupt-suchroutine
such	ldy #0
	lda (3),y
	cmp #$c6	;dec zp
	beq zerop
	cmp #$ce	;dec abs
	beq absol
weiter	inc 3
	bne such
	inc 4
	bne such	;bis $10000 suchen
	lda #55	;programm fertig
	sta 1
	cli	;rom einschalten
	rts	;fertig
; **** dec zeropage gefunden
zerop	iny
	lda (3),y	;zp-adresse
	cmp #2
	beq weiter	;2 nicht erlaubt
	tax
	lda 0,x	;leben
	cmp 2	;mit gesuchter anz. vgl.
	bne weiter
	lda #165	;lda zp
found	pha
	lda #55
	sta 1	;rom ein
	ldy #4	;fuenf zeichen
poout	lda pot,y	;'poke' ausgeben
	jsr $ffd2
	dey
	bpl poout
; **** fundadresse und poke-wert ausgeben
	ldx 3
	lda 4
	jsr $bdcd
	lda #","
	jsr $ffd2
	pla
	pha
	tax
	lda #0
	jsr $bdcd	;dez.
	jsr $ab3f	;space
	jsr $ffd2
	jsr $ffd2
	lda #"$"
	jsr $ffd2	;hex-ausgabe
	lda 4
	jsr hex
	lda 3
	jsr hex
	jsr $ab3f
	pla
	jsr hex
	jsr $aad7	;und fertig
	lda #48
	sei
	sta 1
	jmp weiter	;im ram weitersuchen
; **** dec absolut gefunden
absol	iny
	lda (3),y
	sta 5
	iny
	lda (3),y
	sta 6	;betr. speicherzelle
	ldy #0
	lda (5),y	;anz. leben
	cmp 2
	bne weiter
	lda #173
	bne found	;gleich
; **** wert hexadezimal ausgeben
hex	pha
	lsr
	lsr
	lsr
	lsr	;high-nibble
	jsr hex1
	pla	;low-nibble
hex1	and #15
	tax
	lda hext,x
	jmp $ffd2	;ein nibble ausgeben
; **** ascii-texte
fra	.byt 13
	.byte "how many lives now? 3\x9d"
	brk
pot	.byte " ekop"
hext	.byte "0123456789abcdef"
